package com.liusand.exception;

import com.liusand.common.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author :liusha
 * packageName :com.liusand.exception
 * fileName :GobalExceptionHandler
 * creationTime :2022/11/21 15:24
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(TokenException.class)
    public Result tokenHandler(TokenException exception){
        return new Result(0,"NOTLOGIN", null);
    }

    @ExceptionHandler(EmployeeException.class)
    public Result loginHandler(EmployeeException exception){
        return Result.error(exception.getMessage());
    }

    @ExceptionHandler(CategoryException.class)
    public Result categoryHandler(CategoryException exception){
        return Result.error(exception.getMessage());
    }

    @ExceptionHandler(DishException.class)
    public Result dishHandler(DishException exception){
        return Result.error(exception.getMessage());
    }

    @ExceptionHandler(SetmealException.class)
    public Result setmealHandler(SetmealException exception){
        return Result.error(exception.getMessage());
    }

    @ExceptionHandler(SendSmsException.class)
    public Result sendSmsHandler(SendSmsException exception){
        return Result.error(exception.getMessage());
    }

    @ExceptionHandler(UserException.class)
    public Result userHandler(UserException exception){
        return Result.error(exception.getMessage());
    }

}
